package com.tigercel.xiangchengyun.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.tigercel.xiangchengyun.R;
import com.tigercel.xiangchengyun.entity.HotVideoEntity;

import java.util.List;

/**
 * Created by wqj on 2018/5/26.
 */
public class HotVideoAdapterRecyclerview extends RecyclerView.Adapter<HotVideoAdapterRecyclerview.MyViewHolder> {

    private Context mContext;
    private List<HotVideoEntity> dataList;

    public HotVideoAdapterRecyclerview(Context context, List<HotVideoEntity> dataList) {
        mContext = context;
        this.dataList = dataList;
    }


    @Override
    public HotVideoAdapterRecyclerview.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        HotVideoAdapterRecyclerview.MyViewHolder holder = new HotVideoAdapterRecyclerview.MyViewHolder(LayoutInflater.from(
                mContext).inflate(R.layout.item_hot_video, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(HotVideoAdapterRecyclerview.MyViewHolder holder, int position) {
        holder.tv.setText(dataList.get(position).getTitle());
        Glide.with(mContext).load(dataList.get(position).getThumb_img()).into(holder.img);
    }


    @Override
    public int getItemCount() {
        return dataList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv;
        ImageView img;

        public MyViewHolder(View view) {
            super(view);
            tv = view.findViewById(R.id.videoname);
            img = view.findViewById(R.id.videoimage);
        }
    }
}
